package kitread.util;

import java.awt.image.BufferedImage;
import java.io.IOException;
import java.net.URL;

import javax.imageio.ImageIO;

public class ImageExtractor {

	private static final String GOOGLE_FAVICON_PARSER = "http://www.google.com/s2/favicons?domain=";
	private static ImageExtractor instance = new ImageExtractor();
	
	public static ImageExtractor instance() {
		return instance;
	}
	
	public BufferedImage getIcon(URL url) {
		String domain = url.getHost();
		try {
			return ImageIO.read(new URL(GOOGLE_FAVICON_PARSER + domain));
		} catch (IOException e) {
			e.printStackTrace();
		}
		return null;
	}
}
